package com.miao.manage.web.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.miao.entity.TbItemDesc;
import com.miao.service.TbItemDescService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 商品描述表 前端控制器
 * </p>
 *
 * @author shuangshuang
 * @since 2018-09-07
 */
@Controller
@RequestMapping("/tbItemDesc")
public class TbItemDescController {

    //日志
    private static final Logger LOGGER = LoggerFactory.getLogger(TbItemCatController.class);
    @Autowired
    private TbItemDescService tbItemDescService;

    /**
     * 通过商品ID查询商品描述
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "{id}",method =RequestMethod.GET)
    public ResponseEntity<TbItemDesc> queryid(@PathVariable("id") Long item_id){
        try{
            TbItemDesc tbItemDescs = new TbItemDesc();
            EntityWrapper<TbItemDesc> wrapper = new EntityWrapper<>();
            wrapper.setSqlSelect("created","updated","item_id","item_desc");
            wrapper.setEntity(tbItemDescs);
            wrapper.where("item_id={0}",item_id);
            TbItemDesc tbItemDesc = tbItemDescService.selectOne(wrapper);
            return ResponseEntity.ok(tbItemDesc);
        }catch (Exception e){
            LOGGER.error("查询失败！",e);
        }
       return ResponseEntity.status(HttpStatus.INSUFFICIENT_STORAGE).body(null);
    }


}

